<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>资源列表</title>
 <%@ include file="/commons/basejs.jsp"%> 
  <link rel="stylesheet" href="${staticPath}/static/layuitree/layui/css/layui.css">
  <script type="text/javascript" src="${staticPath}/static/layuitree/layui/layui.js"></script>
</head>
<body>
	<div class="layui-col-md13">
	</br>
		<div class="layui-btn-group">
			<button class="layui-btn layui-btn-normal" data-type="add">
				<i class="layui-icon">&#xe608;</i>新增
			</button>
		</div>
		<button class="layui-btn layui-btn-sm icon-position-no-button"
			id="refresh" style="float: right;"
			onclick="javascript:location.replace(location.href);">
			<i class="layui-icon i-icon" style="font-size: 21px">ဂ</i>
		</button>
	</div>
	<div id="menuTree"></div>
</body>
<script type="text/javascript"
	src="${staticPath}/static/layuitree/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">
  function del(nodeId) {
    console.info(nodeId);
    alert(nodeId);
  }

  var layout = [
    { name: '菜单名称', treeNodes: true, headerClass: 'value_col', colClass: 'value_col', style: 'width: 10%' }, 
    { name: 'url',headerClass: 'value_col', colClass: 'value_col', style: 'width: 10%',
      render: function(row) {
        return '<div class="layui-table-cell laytable-cell-1-username">'+(row.url==null?'':row.url)+'</div>'; //列渲染
      }
    }, { name: '类型',headerClass: 'value_col', colClass: 'value_col', style: 'width: 10%',
      render: function(row) {
        return '<div class="layui-table-cell laytable-cell-1-username">'+(row.resourceType=="1"?'按钮':'菜单')+'</div>'; //列渲染
      }
    }, { name: '权限',headerClass: 'value_col', colClass: 'value_col', style: 'width: 10%',
      render: function(row) {
        return '<div class="layui-table-cell laytable-cell-1-username">'+(row.permission==null?'':row.permission)+'</div>'; //列渲染
      }
    },{ name: '图标',headerClass: 'value_col', colClass: 'value_col', style: 'width: 5%',
      render: function(row) {
        return '<div class="layui-table-cell laytable-cell-1-username"><i class="layui-icon">'+(row.icon==null?'':row.icon)+'</i></div>'; //列渲染
      }
    },{ name: '序号',headerClass: 'value_col', colClass: 'value_col', style: 'width: 5%',
          render: function(row) {
              return '<div class="layui-table-cell laytable-cell-1-username"><i class="layui-icon">'+(row.seq==null?'':row.seq)+'</i></div>'; //列渲染
          }
      },

    {
      name: '操作',
      headerClass: 'value_col',
      colClass: 'value_col',
      style: 'width: 16%',
      render: function(row) {
     //   var chil_len=row.children.length;
        var str= '<a class="layui-btn layui-btn-primary layui-btn-xs" onclick="del(\'' + row.id + '\')"><i class="layui-icon">&#xe615;</i> 查看</a>' +
            '<a class="layui-btn layui-btn-xs  layui-btn-normal" onclick="del(\'' + row.id + '\')"><i class="layui-icon">&#xe642;</i> 编辑</a>'; //列渲染
      //  if(chil_len==0){
          str+='<a class="layui-btn layui-btn-danger layui-btn-xs" onclick="del(\'' + row.id + '\')"><i class="layui-icon">&#xe640;</i> 删除</a>';
      //  }
        return str;
      }
    },
  ];

  layui.use(['tree', 'layer'], function() {
    var layer = layui.layer;
    var resTreeTable = ${resTreeTable};
    layui.treeGird({
      elem: '#menuTree',
      nodes: resTreeTable,
      layout: layout
    });
    
    var $ = layui.$, active = {
        add: function () {
            add('添加菜单', 'showAddMenu', 700, 450);
        }
    }
    $('.layui-btn-group .layui-btn').on('click', function () {
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
  })
  
  
  function add(title, url, w, h) {
    dream_full_show(title, url, w, h);
  };

</script>
</html>
